import matplotlib.pyplot as plt
import seaborn as sns
def barw(ax,data):#计算权重
    """

    :param ax:      sns.countpot对象
    :param data:    数据
    :return:        绘制的图像
    """
    for p in ax.patches:
        val=p.get_width()
        x=p.get_x()+p.get_width()
        y=p.get_y()+p.get_height()/2
        ax.annotate(round(val,2),(x,y))
    plt.figure(figsize=(15, 30))
    ax0 = sns.countplot(y=data['year'], order=data['year'].value_counts().index)
    barw(ax0)